home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / a56 / src / torom.c < prev   
C/C++ Source or Header  |  1995-04-27  |  2KB  |  67 lines

  1. /*******************************************************
  2.  *
  3.  *  a56 - a DSP56001 assembler
  4.  *
  5.  *  Written by Quinn C. Jensen
  6.  *  July 1990
  7.  *
  8.  *******************************************************\
  9.  
  10. /*
  11.  * Copyright (C) 1990-1994 Quinn C. Jensen
  12.  *
  13.  * Permission to use, copy, modify, distribute, and sell this software
  14.  * and its documentation for any purpose is hereby granted without fee,
  15.  * provided that the above copyright notice appear in all copies and
  16.  * that both that copyright notice and this permission notice appear
  17.  * in supporting documentation.  The author makes no representations
  18.  * about the suitability of this software for any purpose.  It is
  19.  * provided "as is" without express or implied warranty.
  20.  *
  21.  */
  22. static char *Copyright = "Copyright (C) 1990-1994 Quinn C. Jensen";
  23.  
  24. /*
  25.  *  This program converts the a56.out assembler output file into
  26.  *  raw binary, suitable for conversion to S-records for an EPROM burner.
  27.  *
  28.  */
  29.  
  30.  
  31. #define MAX 256
  32.  
  33. main(argc,argv)
  34. int argc;
  35. char *argv[];
  36. {
  37.     char buf[MAX];
  38.     int curaddr = 0;
  39.     int line = 0;
  40.  
  41.     while(gets(buf)) {
  42.     char seg;
  43.     int addr, data;
  44.     line++;
  45.     if(sscanf(buf, "%c%x%x", &seg, &addr, &data) == 3) {
  46.         if(addr < curaddr) {
  47.         fatal("%s: input line %d: can't go back\n", argv[0], line);
  48.         } else if(addr != curaddr) {
  49.         while(curaddr < addr) {
  50.             putword(0);
  51.             curaddr++;
  52.         }
  53.         }
  54.         putword(data);
  55.         curaddr++;
  56.     }
  57.     }
  58. }
  59.  
  60. putword(data)
  61. int data;
  62. {
  63.     putchar(data >>  0 & 0xFF);
  64.     putchar(data >>  8 & 0xFF);
  65.     putchar(data >> 16 & 0xFF);
  66. }
  67.